package com.act.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import com.act.dao.IRewardDao;
import com.act.domain.Reward;
import com.act.dto.PagerDTO;
import com.act.service.api.IRewardService;
import com.act.vo.PagerVo;

/**
* @Desccription:类说明
* @Author: 刘承军
* @E-mail:923050345@qq.com
* @Date:2017年11月6日 下午2:08:59  
*/

@Service
public class RewardServiceImpl implements IRewardService{

	@Resource
	private IRewardDao rewardDao;
	
	@Override
	public void add(Reward reward) {
		rewardDao.add(reward);
	}

	@Override
	public void update(Reward reward) {
		rewardDao.update(reward);
	}

	@Override
	public void delete(int id) {
		rewardDao.delete(id);
	}

	@Override
	public PagerVo<Map> getRewardByJobnum(@Param("pagerDTO")PagerDTO pagerDTO, @Param("jobnum")String jobnum) {
		int startIndex = pagerDTO.getStartIndex();
		int endIndex = pagerDTO.getEndIndex();
		int totalCounts = rewardDao.getCounts(jobnum);
		List<Map> list =rewardDao.getRewardByJobnum(jobnum, startIndex, endIndex);
		PagerVo<Map> pagerVo = new PagerVo<>(pagerDTO.getPageIndex(),pagerDTO.getPageSize(),totalCounts,list);

		return pagerVo;
	}

	@Override
	public Reward getById(@Param("id")int id) {
		
		return rewardDao.getById(id);
	}

	@Override
	public PagerVo<Map> getAll(@Param("pagerDTO")PagerDTO pagerDTO) {
		int startIndex = pagerDTO.getStartIndex();
		int endIndex = pagerDTO.getEndIndex();
		int totalCounts = rewardDao.getCounts(null);
		List<Map> list =rewardDao.getAll(startIndex, endIndex);
		PagerVo<Map> pagerVo = new PagerVo<>(pagerDTO.getPageIndex(),pagerDTO.getPageSize(),totalCounts,list);

		return pagerVo;
	}

}
